package com.liveinstars.im.endpoint;

import com.liveinstars.api.im.ChatGroupApiService;
import com.liveinstars.api.im.IMUserApiService;
import com.liveinstars.api.im.vo.ChatGroupDto;
import com.liveinstars.api.im.vo.ChatGroupRecordVO;
import com.liveinstars.api.im.vo.NoticeMessageVO;
import com.liveinstars.api.im.vo.NoticeVO;
import com.onepiece.shipelves.common.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Api(value = "chatgroup api")
@RestController
public class ChatGroupApiEndPoint implements ChatGroupApiService {

    @Autowired
    @Qualifier("chatGroupApiServiceApiImpl")
    ChatGroupApiService chatGroupApiService;


    @ApiOperation(value="创建小圈", notes="创建小圈")
    @Override
    public Result<ChatGroupRecordVO> createChatGroup(@RequestParam(value = "name", defaultValue = "") String name,
                                                     @RequestParam(value = "userId", defaultValue = "") Long userId,
                                                     @RequestParam(value = "users", defaultValue = "") String users,
                                                     @RequestParam(value = "desc", defaultValue = "") String desc,
                                                     @RequestParam(value = "type", defaultValue = "6") Integer type,
                                                     @RequestParam(value = "user_level", defaultValue = "0") Integer user_level,
                                                     @RequestParam(value = "logo", defaultValue = "") String logo,
                                                     @RequestParam(value = "interest_id", defaultValue = "") Integer interestId) {
        return chatGroupApiService.createChatGroup(name, userId, users, desc, type, user_level, logo, interestId);
    }


    @ApiOperation(value="更新小圈", notes="更新小圈")
    @Override
    public Result<ChatGroupRecordVO> updateChatGroup(@RequestParam(value = "chatGroupId", defaultValue = "") Long chatGroupId,
                                  @RequestParam(value = "name", defaultValue = "") String name,
                                  @RequestParam(value = "userId", defaultValue = "") Long userId,
                                  @RequestParam(value = "desc", defaultValue = "") String desc,
                                  @RequestParam(value = "logo", defaultValue = "") String logo,
                                  @RequestParam(value = "user_level", defaultValue = "") Integer user_level,
                                  @RequestParam(value = "authRule", defaultValue = "") Integer authRule) {
        return chatGroupApiService.updateChatGroup(chatGroupId, name, userId, desc, logo, user_level, authRule);
    }

    @Override
    public Result<NoticeVO> getNotice(@RequestParam(value = "chat_group_id", defaultValue = "") Long chatGroupId) {
        return chatGroupApiService.getNotice(chatGroupId);
    }

    @Override
    public String shieldChatGroup(@RequestParam(value = "chatGroupId", defaultValue = "") Long chatGroupId,
                                  @RequestParam(value = "userId", defaultValue = "") Long userId,
                                  @RequestParam(value = "shieldUserId", defaultValue = "") Long shieldUserId, Integer shieldTime) {
        return chatGroupApiService.shieldChatGroup(chatGroupId, userId, shieldUserId, shieldTime);
    }


    @Override
    public String noDisturbChatGroup(@RequestParam(value = "chatGroupId", defaultValue = "") Long chatGroupId,
                                     @RequestParam(value = "userId", defaultValue = "") Long userId) {
        return chatGroupApiService.noDisturbChatGroup(chatGroupId, userId);
    }

    @Override
    public String getChatGroup(@RequestParam(value = "chatGroupId", defaultValue = "") Long chatGroupId,
                               @RequestParam(value = "userId", defaultValue = "") Long userId) {
        return chatGroupApiService.getChatGroup(chatGroupId, userId);
    }

    @Override
    public String getChatGroupList(
            @RequestParam(value = "userId", defaultValue = "") Long userId,
            @RequestParam(value = "groupType", defaultValue = "") Integer groupType,
            @RequestParam(value = "groupPage", defaultValue = "") Integer groupPage,
            @RequestParam(value = "groupCount", defaultValue = "") Integer groupCount) {
        return chatGroupApiService.getChatGroupList(userId, groupType, groupPage, groupCount);
    }

    @Override
    public String listHotChatGroup(@RequestParam(value = "userId", defaultValue = "") Long userId) {
        return chatGroupApiService.listHotChatGroup(userId);
    }

    @Override
    public String getChatGroupByCreateUid(@RequestParam(value = "userId", defaultValue = "") Long userId) {
        return chatGroupApiService.getChatGroupByCreateUid(userId);
    }

    @Override
    public String getChatGroupByUid(@RequestParam(value = "userId", defaultValue = "") Long userId) {
        return chatGroupApiService.getChatGroupByUid(userId);
    }

    @Override
    public List<ChatGroupDto> getChatGroupListByUid(@RequestParam(value = "userId", defaultValue = "") Long userId) {
        return chatGroupApiService.getChatGroupListByUid(userId);
    }

    @Override
    public String leaveChatGroup(@RequestParam(value = "chatGroupId", defaultValue = "") Long chatGroupId,
                                 @RequestParam(value = "userId", defaultValue = "") Long userId) {
        return chatGroupApiService.leaveChatGroup(chatGroupId, userId);
    }

    @Override
    public String dissolveChatGroup(@RequestParam(value = "chatGroupId", defaultValue = "") Long chatGroupId,
                                    @RequestParam(value = "userId", defaultValue = "") Long userId) {
        return chatGroupApiService.dissolveChatGroup(chatGroupId, userId);
    }

    @Override
    public String kickOutChatGroup(@RequestParam(value = "chatGroupId", defaultValue = "") Long chatGroupId,
                                   @RequestParam(value = "userId", defaultValue = "") Long userId,
                                   @RequestParam(value = "kickWho", defaultValue = "") String kickWho) {
        return chatGroupApiService.kickOutChatGroup(chatGroupId, userId, kickWho);
    }

    @Override
    public String getChatGroupMember(@RequestParam(value = "chatGroupId", defaultValue = "") Long chatGroupId,
                                     @RequestParam(value = "userId", defaultValue = "") Long userId) {
        return chatGroupApiService.getChatGroupMember(chatGroupId, userId);
    }

    @Override
    public String joinChatGroup(@RequestParam(value = "chatGroupId", defaultValue = "") Long chatGroupId,
                                @RequestParam(value = "userId", defaultValue = "") Long userId,
                                @RequestParam(value = "reqMsg", defaultValue = "") String reqMsg) {
        return chatGroupApiService.joinChatGroup(chatGroupId, userId, reqMsg);
    }

    @Override
    public Result<Boolean> isHasGroupCreate(@RequestParam(value = "userId", defaultValue = "") Long userId) {
        return chatGroupApiService.isHasGroupCreate(userId);
    }

    @Override
    public Boolean makeFriend(@RequestParam(value = "friendId", defaultValue = "") Long friendId,
					   @RequestParam(value = "userId", defaultValue = "")  Long userId) {
        return chatGroupApiService.makeFriend(friendId, userId);
    }

    @Override
    public Boolean isFriend(@RequestParam(value = "userId", defaultValue = "") Long userId,
                                    @RequestParam(value = "myId", defaultValue = "") Long myId) {
        return chatGroupApiService.isFriend(userId, myId);
    }

    @Override
    public Boolean sendMessage(@RequestBody NoticeMessageVO messageVO) {
        return chatGroupApiService.sendMessage(messageVO);
    }
}
